<?php
$mysql_server_name = 'localhost'; //数据库服务器名称
$mysql_username = 'kglife_url'; // 连接数据库用户名
$mysql_password = 'C1Sb75S3'; // 连接数据库密码
$mysql_database = 'kglife_kg_url'; // 数据库的名字
$url_tab = 'kg_url';
//define('URL_TAB','kg_url');
$db = mysql_connect($mysql_server_name, $mysql_username, $mysql_password);

//十进制转到其他制  
function dec2any($num, $base=62, $index=false) {
    if (!$base) {
        $base = strlen($index);
    } elseif (!$index) {
        $index = substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base);
    }
    $out = "";
    for ($t = floor(log10($num) / log10($base)); $t >= 0; $t--) {
        $a = floor($num / pow($base, $t));
        $out = $out . substr($index, $a, 1);
        $num = $num - ( $a * pow($base, $t) );
    }
    return $out;
}

function any2dec($num, $base=62, $index=false) {
    if (!$base) {
        $base = strlen($index);
    } elseif (!$index) {
        $index = substr("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", 0, $base);
    }
    $out = 0;
    $len = strlen($num) - 1;
    for ($t = 0; $t <= $len; $t++) {
        $out = $out + strpos($index, substr($num, $t, 1)) * pow($base, $len - $t);
    }
    return $out;
}

?>
